/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
    position: relative;
}

.logo {
    padding: 2rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h2 {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

/* 全局项目选择器 */
.global-project-selector {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.global-project-selector label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
    font-weight: 500;
}

.global-project-selector select {
    width: 100%;
    padding: 0.6rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.global-project-selector select:hover {
    background: rgba(255, 255, 255, 0.2);
}

.global-project-selector select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.global-project-selector select option {
    background: #333;
    color: white;
}

.current-project-info {
    margin-top: 0.8rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

/* 项目状态显示 */
.project-status {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f0f4f8;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.project-status .status-text {
    font-size: 0.9rem;
    color: #4a5568;
}

.project-status strong {
    color: #2d3748;
    margin-left: 0.3rem;
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    margin-top: 0.5rem;
}

.nav-menu li {
    margin: 0.3rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    font-weight: 500;
    border-radius: 0 6px 6px 0;
    margin-right: 0.5rem;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: rgba(255, 255, 255, 0.5);
    transform: translateX(3px);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.2rem;
    border-bottom: 2px solid #e1e8ed;
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100px;
    height: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.page-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #2d3748;
    position: relative;
    padding-left: 0.5rem;
}

.page-header h1::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10%;
    height: 80%;
    width: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.header-actions {
    display: flex;
    gap: 1.2rem;
    align-items: center;
}

/* 按钮样式 */
.btn {
    padding: 0.8rem 1.6rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.25);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    box-shadow: 0 4px 10px rgba(108, 117, 125, 0.25);
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(108, 117, 125, 0.4);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.25);
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(220, 53, 69, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* 项目网格 */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: white;
    border-radius: 12px;
    padding: 1.8rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0.7;
    transition: height 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.project-card:hover::before {
    height: 6px;
}

.project-card h3 {
    color: #2c3e50;
    margin-bottom: 0.8rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.project-card p {
    color: #64748b;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
    min-height: 3rem;
}

.project-card-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

.project-card-actions .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.project-card-actions .btn-primary {
    flex-grow: 2;
}

.project-card-actions .btn-danger {
    flex-grow: 1;
}

/* 训练数据样式 */
.training-data-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.filter-tabs {
    display: flex;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
}

.tab-btn {
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background-color: white;
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.tab-btn:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.training-data-list {
    padding: 1.5rem;
}

.training-data-item {
    padding: 1.5rem;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #f8f9fa;
}

.training-data-item:last-child {
    margin-bottom: 0;
}

.training-data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.training-data-type {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.training-data-content {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

/* SQL生成和纠错页面 */
.generator-container,
.corrector-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.input-section,
.output-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.sql-output {
    position: relative;
    background: #2d3748;
    border-radius: 8px;
    overflow: hidden;
}

.sql-output pre {
    margin: 0;
    padding: 1.5rem;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.3s ease;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 历史记录样式 */
.history-list {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.history-item {
    padding: 1.5rem;
    border-bottom: 1px solid #e1e8ed;
}

.history-item:last-child {
    border-bottom: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-type {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.history-type.generation {
    background: #d4edda;
    color: #155724;
}

.history-type.correction {
    background: #f8d7da;
    color: #721c24;
}

.history-question {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.history-sql {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    border-left: 4px solid #667eea;
}

/* 配置页面 */
.config-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.config-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.config-section h3 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e1e8ed;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e1e8ed;
}

.modal-header h3 {
    color: #2c3e50;
    font-size: 1.25rem;
}

.close {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: #adb5bd;
    transition: color 0.3s ease;
}

.close:hover {
    color: #6c757d;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e1e8ed;
}

/* 加载指示器 */
.loading {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 通知样式 */
.notification {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification.success {
    border-left: 4px solid #28a745;
}

.notification.error {
    border-left: 4px solid #dc3545;
}

.notification button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #adb5bd;
    margin-left: 1rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }
    
    .nav-menu {
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
    }
    
    .nav-menu li {
        margin: 0 0.25rem;
        white-space: nowrap;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    
    .nav-link.active {
        border-left: none;
        border-bottom-color: white;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .generator-container,
    .corrector-container {
        grid-template-columns: 1fr;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .config-container {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state h3 {
    margin-bottom: 1rem;
    color: #adb5bd;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* 工具提示 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #2c3e50;
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8rem;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}